<? 
	
	require("required/dbconnect.php");
	require("required/share_function.php");
	$cat_id=mysql_real_escape_string($_GET['id']);
	
	$get_sub_cat=mysql_query("select * from os_sub_category where id='$cat_id'");
	
	if(mysql_num_rows($get_sub_cat)==0)
	{
		header("Location:os_invalid.php?error=0");
	}
	$main_cat_id=mysql_result($get_sub_cat,0,"main_category");
	$get_cat=mysql_query("select * from os_category where id='$main_cat_id'")or die(mysql_error());
	

	if(empty($_GET['page']))
	{
		$page="1";
	}
	else
	{
		$page=$_GET['page'];
	}
	
	
	
	$totalperpage=15;

	$from=($page-1)*$totalperpage;	
	$get_product=mysql_query("select * from os_products where status=1 and hide_at_products=0 and sub_cat_id=$cat_id order by order_id asc,product_name_eng asc limit $from,$totalperpage")or die(mysql_error());
	$get_total=mysql_query("select * from os_products where status=1 and hide_at_products=0 and sub_cat_id=$cat_id")or die(mysql_error());
	
	
	$count=mysql_num_rows($get_total);

	
	$cat_name=mysql_result($get_cat,0,"name_eng");
	$subcat_name=mysql_result($get_sub_cat,0,"name_eng");
	$_SESSION['pid']=$subcat_name;
	$tr1="";
	$tr2="";
	$title=mysql_result($get_cat,0,"name_eng")." - ".$subcat_name;
	require("required/header.php"); 

?>
			
				<table width="100%" cellpadding="5" cellspacing="0">
					
                   <Tr>
                      <Td  class="page_location" colspan="2">Your Location : <a href="index.php">Home</a>  > <a href="os_products.php?pid=<?= $main_cat_id ?>"><?= $cat_name ?></a> > 
                      <?= $subcat_name ?></Td>
                            
                   </Tr>
                   
					<tr>
                   		<Td width="20%" valign="top">
                        	<? 
							
								require("required/product_category.php"); 
							
							?>
                        	
                        </Td>
                        <td width="80%" valign="top">
                        	
							<table width="100%">
                            	
							<?	
								if($count==0)
								{
							?>
								<tr>
									<td align="center"> <br /><br /><br />:: NO RECORD :: </td>
								</tr>
							<?	
								}
								else
								{
							?>
							<tr>
								<td width="100%" colspan="6" align="center">
									<table width="100%" cellpadding="0" cellspacing="0" >
										
                                        <tr>
                                         	<td align="left">
                                            	<?= getPaging($totalperpage,$count,$page,"os_view_product.php?id=$cat_id") ?>
                                            </td>
                                         
                                        </tr>						
									</table>
								</td>
							</tr>
                            <tr>
                            	<td colspan="6">
                                	<table>
									<?	productAvatar($get_product); ?>
                            		</table>
                                </td>
                            </tr>                            
							<tr>
								<td width="100%" colspan="6" align="left">
                                
									<?= getPaging($totalperpage,$count,$page,"os_view_product.php?id=$cat_id") ?>
								</td>
								
							</tr>
                            <? } ?>
							</table>
						</Td>
					</tr>		  
			  	</table>
			
<? require("required/footer.php"); ?>	